package com.goldwind.accompany.controller;

import com.goldwind.accompany.service.impl.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/oss")
public class OssController {

    private final OssService ossService;

    @Autowired
    public OssController(OssService ossService) {
        this.ossService = ossService;
    }

    @GetMapping("/policy")
    public Map<String, String> getUploadPolicy(@RequestParam(defaultValue = "com/goldwind/accompany/") String dir) {
        return ossService.generateUploadPolicy(dir);
    }
}
